package com.my.rabbitmq.six;

import com.my.utils.RabbitMQUtils;
import com.rabbitmq.client.Channel;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2023/11/30 12:38
 */

// 生产者
public class EmitLogTopic {

    // 交换机名称
    public static final String EXCHANGE_NAME = "topic_logs";

    public static void main(String[] args) throws Exception{

        Map<String, String> bindingKeyMap = new HashMap<>();
        bindingKeyMap.put("quick.orange.rabbit", "被队列Q1Q2接收到");
        bindingKeyMap.put("lazy.orange.elephant", "被队列Q1Q2接收到");
        bindingKeyMap.put("quick.orange.fox", "被队列Q1接收到");
        bindingKeyMap.put("lazy.brown.fox", "被队列Q2接收到");
        bindingKeyMap.put("lazy.pink.rabbit", "被队列Q2接收到");
        bindingKeyMap.put("quick.browm.fox", "被丢弃");
        bindingKeyMap.put("quick.orange.male.rabbit", "被丢弃");
        bindingKeyMap.put("lazy.orange.male.rabbit", "被队列Q2接收到");

        Channel channel = RabbitMQUtils.getChannel();
        for (Map.Entry<String, String> entry : bindingKeyMap.entrySet()) {
            channel.basicPublish(EXCHANGE_NAME, entry.getKey(), null, entry.getValue().getBytes("UTF-8"));
            System.out.println("生产者发出消息：" + entry.getValue());
        }

    }
}
